package data;

import com.EntityName;
import com.google.appengine.api.datastore.Entity;
import com.google.appengine.api.datastore.Text;

public class WaitToUpdate extends AbstractData{
	private long id = -1;
	private long hotelId;
	private Text data;
	private String type;
	
	public WaitToUpdate(){
	}
	
	public WaitToUpdate(long id){
		this.id = id;
	}
	
	public void setId(long id) {
		this.id = id;
	}
	
	public long getId() {
		return id;
	}

	public Text getData() {
		return data;
	}

	public void setData(Text data) {
		this.data = data;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public long getHotelId() {
		return hotelId;
	}

	public void setHotelId(long hotelId) {
		this.hotelId = hotelId;
	}

	@Override
	public Entity getEntity() {
		Entity item;
		if(this.key == null)
			item = new Entity(EntityName.WaitToUpdate);
		else
			item = new Entity(this.key);
		item.setProperty("hotelId", this.hotelId);
		item.setProperty("data", this.data);
		item.setProperty("class", this.type);
		
		return item;
	}

	@Override
	public void setEntity(Entity entity) {
		this.id = entity.getKey().getId();
		this.hotelId = (Long) entity.getProperty("hotelId");
		this.data = (Text) entity.getProperty("data");
		this.type = (String) entity.getProperty("class");
		
		this.key = entity.getKey();
	}
	
	public void LoadData() {
		if (this.id > -1) {
			Entity entity = LoadData(EntityName.WaitToUpdate, this.id);
			setEntity(entity);
		}
	}

}
